package com.team.recruitment_management_system.config;

import com.team.recruitment_management_system.interceptor.LoginProtectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginProtectInterceptor loginProtectInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginProtectInterceptor).addPathPatterns("/**")
                .excludePathPatterns(
                        "/webjars/**",
                        "/doc.html/**",
                        "/v3/api-docs/**",
                        "/image/**",
                        "/auth/**",
                        "/email/captcha/pwd/**",
                        "/email/captcha/login/**",
                        "/company/info/**",
                        "/company/more",
                        "/company/hot",
                        "/job/more",
                        "/job/hot",
                        "/job/info/**",
                        "/job/company/**",
                        "/tag/getAll"
                );
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/image/**").addResourceLocations("file:F:\\upload/");
    }

}
